package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/2/25 16:16
 * @description
 */
public class Code189 {
    public void rotate(int[] nums, int k) {
        while (k > nums.length) {
            k -= nums.length;
        }
        int[] lefts = new int[k];
        for (int i = nums.length - k, j = 0; i < nums.length; i++, j++) {
            lefts[j] = nums[i];
        }
        System.arraycopy(nums, 0, nums, k, nums.length - k);
        for (int i = 0; i < lefts.length; i++) {
            nums[i] = lefts[i];
        }
    }
}
